package org.kl.bf.entity.basic;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.kl.bf.entity.AuditableEntity;
import org.kl.bf.entity.Excel;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "basic_role")
public class Role extends AuditableEntity {
	private static final long serialVersionUID = 1L;
	@Excel(exportName = "角色编号")
	private String roleNo;
	@Excel(exportName = "角色名称")
	private String roleName;
	private Set<Menu> roleMenus;
	private Set<Function> roleFunctions;

	@JsonIgnore
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "basic_role_menu", schema = "", joinColumns = { @JoinColumn(name = "role_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "menu_id", nullable = false, updatable = false) })
	public Set<Menu> getRoleMenus() {
		return roleMenus;
	}

	public void setRoleMenus(Set<Menu> roleMenus) {
		this.roleMenus = roleMenus;
	}

	@JsonIgnore
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "basic_role_function", schema = "", joinColumns = { @JoinColumn(name = "role_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "function_id", nullable = false, updatable = false) })
	public Set<Function> getRoleFunctions() {
		return roleFunctions;
	}

	public void setRoleFunctions(Set<Function> roleFunctions) {
		this.roleFunctions = roleFunctions;
	}

	public String getRoleNo() {
		return roleNo;
	}

	public void setRoleNo(String roleNo) {
		this.roleNo = roleNo;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
}